const dontReset = ['/wx/sns/login']

const errCallback: { [key: string]: Function } = {
  async 403(data: any, resolve: any, url: string) {
    if (dontReset.find((v) => url.includes(v))) return
    // 登录
    uni.showModal({
      title: '提示',
      content: '身份校验过期，是否重新登录？',
      confirmText: '确定',
      cancelText: '取消',
      success: async (ret) => {
        if (ret.confirm) {
		  uni.navigateTo({
		  	url: '/pages/login/index'
		  })
          return
        }
        resolve({ success: false, reset: false })
      },
    })
  },
  401(data: any) {},
  notNumber(data: any, resolve: any) {
    uni.showModal({
      title: '温馨提示',
      content: data.msg || data.error || data.errMsg || data.message || '网络异常，请稍后再试',
      showCancel: false,
      success: () => {},
    })
    resolve({ success: false })
  },
  init(code: number, data: any, url?: string) {
    return new Promise((resolve) => {
      if (code === 0) {
        resolve({ success: true })
        return false
      }
      const func = this[code] ? this[code] : this.notNumber
      func(data, resolve, url)
    })
  },
}
export default errCallback

